@extends('layouts.console_header')

@section('title', '夜场管理')

@section('resources')
    @parent

@endsection

@section('content')
<section class="user_list">
    <div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
        <p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;"><a href="/console/index">首页</a>>用户版运营></span><span class="co_violet">夜场管理</span></p>
        <a href="#"><p class="fr tc back_btn">导出</p></a>
    </div>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>一级分类</th>
                <th>二级分类</th>
                <th>商家代码</th>
                <th>门店名称</th>
                <th>联系电话</th>
                <th>最新状态</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>一级分类</th>
                <th>二级分类</th>
                <th>商家代码</th>
                <th>门店名称</th>
                <th>联系电话</th>
                <th>最新状态</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['firstclassname']}}</td>
                    <td>{{$list['secondclassname']}}</td>
                    <td>{{$list['code']}}</td>
                    <td>{{$list['name']}}</td>
                    <td>{{$list['contactnumber']}}</td>
                    <td>参与</td>
                    <td>{{$list['updated_at']}}</td>
                    <td>
                        <a class="co_violet" href="/console/shop/get?cityid={{$cityid}}&shopid={{$list['shopid']}}">详情</a> &nbsp; &nbsp;
                    @if($list['forbidnightevent'] == '0')
                        <a class="co_violet" href="" onclick="forbid_shop_night({{$list['shopid']}})">禁止</a>
                    @else
                        <a class="co_violet" href="" onclick="open_shop_night({{$list['shopid']}})">恢复</a>
                    @endif
                    </td>

                </tr>
            @endforeach
        </tbody>
    </table>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        var cityid='{{$cityid}}';
        function forbid_shop_night(shopid) {
            var isconfirm = confirm("确定要禁止夜场?");
            if(isconfirm) {
                $.ajax({
                    url : '/console/shop/night/forbid/update',
                    type : 'post',
                    data: {
                        'shopid':shopid,
                        'cityid':cityid,
                        'type': '1'
                    },
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            location.reload();
                        } else {
                            alert(data.message);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            }
        }
        function open_shop_night(shopid) {
            var isconfirm = confirm("确定要恢复夜场?");
            if(isconfirm) {
                $.ajax({
                    url : '/console/shop/night/forbid/update',
                    type : 'post',
                    data: {
                        'shopid':shopid,
                        'cityid':cityid,
                        'type': '0'
                    },
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            location.reload();
                        } else {
                            alert(data.message);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            }
        }
    </script>
@endsection